package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 安慕希
 * Date: 2025-03-16
 * Time: 17:06
 */
public class Dog extends Animal{
    String name;
    int age;

    public Dog(String name, int i) {

    }

    final public void bark(){//加了final之后方法也不能被重写了
        System.out.println("汪汪");
    }
    private void fight(){//加了private static 以及final的方法均不能被改写
        System.out.println("Cat can't beat Dog");
    }


    @Override
    public void eat() {
        System.out.println(this.name+"正在吃狗粮");
    }



/*    if(animal instanceof Dog){
        Animal animal = new Dog("小白", 4);
        Dog dog4 = (Dog) animal;
        //向下转型设计到强行转换
        //不安全，建议加上instanceof语句判断
    }else{
        System.out.println(" ");
    }*/





}
